import Vue from 'vue'
import VueRouter from 'vue-router'

//布局
const Layout = () => import('../views/layout')
//登录页面
const Login = () => import('../views/login')
//主页面
const Home = () => import('../views/home')
//商品列表
const Goods_1 = () => import('../views/goods/goods_1.vue')
//添加商品
const Goods_2 = () => import('../views/goods/goods_2.vue')
//商品分类
const Goods_3 = () => import('../views/goods/goods_3.vue')
//商品类型
const Goods_4 = () => import('../views/goods/goods_4.vue')
//品牌管理
const Goods_5 = () => import('../views/goods/goods_5.vue')
//订单设置
const Order_1 = () => import('../views/order/order_1.vue')
//退货申请处理
const Order_2 = () => import('../views/order/order_2.vue')
//退货原因设置
const Order_3 = () => import('../views/order/order_3.vue')
//品牌推荐
const Sale_1 = () => import('../views/sale/sale_1.vue')
//新品推荐
const Sale_2 = () => import('../views/sale/sale_2.vue')
//人气推荐
const Sale_3 = () => import('../views/sale/sale_3.vue')
//用户列表
const Auth_1 = () => import('../views/auth/auth_1.vue')
//角色列表
const Auth_2 = () => import('../views/auth/auth_2.vue')
//菜单列表
const Auth_3 = () => import('../views/auth/auth_3.vue')
//菜单列表
const Auth_4 = () => import('../views/auth/auth_4.vue')

Vue.use(VueRouter)

export const constantRouterMap = [
	{
		path: '/login',
		name: 'Login',
		component: Login,
		meta: {
			title: '登录',
		},
	},
	{
		path: '',
		redirect: '/home',
		component: Layout,
		meta: {
			title: '布局',
		},
		children: [
			{
				path: 'home',
				name: 'Home',
				component: Home,
				meta: {
					title: '主页',
					icon: 'el-icon-s-home',
				},
			},
		],
	},
	{
		path: '*',
		redirect: '/home',
	},
]

export const asyncRouterMap = [
	{
		path: '/goods',
		redirect: '/goods/goods_1',
		component: Layout,
		name: 'Goods',
		meta: {
			title: '商品',
			icon: '',
		},
		children: [
			{
				path: 'goods_1',
				name: 'Goods_1',
				component: Goods_1,
				meta: {
					title: '商品列表',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'goods_2',
				name: 'Goods_2',
				component: Goods_2,
				meta: {
					title: '添加商品',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'goods_3',
				name: 'Goods_3',
				component: Goods_3,
				meta: {
					title: '商品分类',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'goods_4',
				name: 'Goods_4',
				component: Goods_4,
				meta: {
					title: '商品类型',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'goods_5',
				name: 'Goods_5',
				component: Goods_5,
				meta: {
					title: '品牌管理',
					icon: 'el-icon-s-home',
				},
			},
		],
	},
	{
		path: '/order',
		redirect: '/order/order_1',
		component: Layout,
		name: 'Order',
		meta: {
			title: '订单',
			icon: '',
		},
		children: [
			{
				path: 'order_1',
				name: 'Order_1',
				component: Order_1,
				meta: {
					title: '订单列表',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'order_2',
				name: 'Order_2',
				component: Order_2,
				meta: {
					title: '订单设置',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'order_3',
				name: 'Order_3',
				component: Order_3,
				meta: {
					title: '退货申请处理',
					icon: 'el-icon-s-home',
				},
			},
		],
	},
	{
		path: '/sale',
		redirect: '/sale/sale_1',
		component: Layout,
		name: 'Sale',
		meta: {
			title: '营销',
			icon: '',
		},
		children: [
			{
				path: 'sale_1',
				name: 'Sale_1',
				component: Sale_1,
				meta: {
					title: '品牌推荐',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'sale_2',
				name: 'Sale_2',
				component: Sale_2,
				meta: {
					title: '新品推荐',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'sale_3',
				name: 'Sale_3',
				component: Sale_3,
				meta: {
					title: '人气推荐',
					icon: 'el-icon-s-home',
				},
			},
		],
	},
	{
		path: '/auth',
		redirect: '/auth/auth_1',
		component: Layout,
		name: 'Auth',
		meta: {
			title: '权限',
			icon: '',
		},
		children: [
			{
				path: 'auth_1',
				name: 'Auth_1',
				component: Auth_1,
				meta: {
					title: '商品列表',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'auth_2',
				name: 'Auth_2',
				component: Auth_2,
				meta: {
					title: '商品列表',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'auth_3',
				name: 'Auth_3',
				component: Auth_3,
				meta: {
					title: '商品列表',
					icon: 'el-icon-s-home',
				},
			},
			{
				path: 'auth_4',
				name: 'Auth_4',
				component: Auth_4,
				meta: {
					title: '商品列表',
					icon: 'el-icon-s-home',
				},
			},
		],
	},
]

const router = new VueRouter({
	routes: constantRouterMap,
})

/*
动态菜单：
将路由分为动态路由和静态路由

静态路由无需权限即访问，而动态路由需要根据权限或角色信息来加载
*/


export default router
